<!--
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2024-01-09 09:37:35
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-01-09 09:57:43
 * @FilePath: /hr_new_vue3/src/views/Management/Human/ChangeManagement/InternshipManagement/Evaluation/Components/IntershipEvaluation/Components/FromSetting/Components/SelectedScorerModal/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 选中评分人 -->
<template>
  <a-modal v-model:visible="modalVisible" @ok="handleOk" @cancel="handleCancel">
    <template #title> 选择人员 </template>
    <a-radio-group direction="vertical" v-model="selectedId" @change="change">
      <a-radio v-for="item in data" :key="item.id" :value="item.id">
        {{ item.name }}
      </a-radio>
    </a-radio-group>
  </a-modal>
</template>
<script setup lang="ts">
import { GetHumanRosterList } from '@/apis/management/human/humanRoster';
import { useVModel } from '@vueuse/core';

const props = withDefaults(
  //参数说明
  defineProps<{
    visible: boolean;
    data: any[];
  }>(),
  {
    visible: false
  }
);
const emits = defineEmits(['update:visible', 'submit']);
const modalVisible = useVModel(props, 'visible', emits);
const selectedId = ref(0);
let selectedData = ref({});

const handleOk = () => {
  modalVisible.value = false;
  emits('submit', selectedData.value);
};
const handleCancel = () => {
  modalVisible.value = false;
};
const change = async (id: number) => {
  selectedData.value = props.data.find((el: any) => el.id === id);
};
watch(
  () => modalVisible.value,
  () => {
    if (!modalVisible.value) return;
    selectedId.value = 0;
  }
);
</script>
